//
//  CYZiXunXiangGuanSouSuoTableViewCell.m
//  cyydt
//
//  Created by chu on 2019/1/23.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYZiXunXiangGuanSouSuoTableViewCell.h"
#import "CYProjectModel.h"
#import "CYArcitleDetailsViewController.h"

@implementation CYZiXunXiangGuanSouSuoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setContentArr:(NSArray *)contentArr{
    _contentArr = contentArr;
    
    for (int i = 0; i < self.xiangguansousuo.count; i++) {
        UILabel *label = self.xiangguansousuo[i];
        CYProjectModel *model = contentArr[i];
        label.text = model.title;
        label.tag = i;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sousuoAction:)];
        [label addGestureRecognizer:tap];
        label.userInteractionEnabled = YES;
    }
    
}

- (void)sousuoAction:(UITapGestureRecognizer *)tap{
    NSInteger tag = tap.view.tag;
    CYProjectModel *model = self.contentArr[tag];
    if (model.url) {
        ZTResourceViewController *resource = [[ZTResourceViewController alloc] init];
        resource.title = model.title;
        resource.url = model.url;
        [[AppDelegate sharedAppDelegate] pushViewController:resource];
    }else{
        CYArcitleDetailsViewController *details = [[CYArcitleDetailsViewController alloc] init];
        details.articleId = [model.ID stringValue];
        [[AppDelegate sharedAppDelegate] pushViewController:details];
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
